package com.lhl.blog.controller;

import com.lhl.blog.common.pojo.request.UserLoginParam;
import com.lhl.blog.common.pojo.response.UserInfoResponse;
import com.lhl.blog.common.pojo.response.UserLoginResponse;
import com.lhl.blog.service.UserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource(name = "userServiceImp")
    private UserService userService;

    @PostMapping("/login")
    public UserLoginResponse login (@Validated @RequestBody UserLoginParam userParam){
      log.info("用户登录，userName：{}",userParam.getUserName());
      return userService.login(userParam);
    }

    @GetMapping("/getUserInfo")
    public UserInfoResponse getUserInfo(Integer userId){
        log.info("获取用户信息，userId：{}",userId);
        return userService.getUserInfo(userId);
    }

    @GetMapping("/getAuthorInfo")
    public UserInfoResponse getAuthorInfo(Integer blogId){
        log.info("获取作者信息，博客Id：{}",blogId);
        return userService.getAuthorInfo(blogId);
    }

}
